<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/22
 * Time: 15:30
 */

class Shopify_url_model extends CI_Model
{
    public $type;

    public function __construct($param = array())
    {
        parent::__construct();
        $this->type = intval($param['type']);
    }

    public function batch_shopify_url($data = array())
    {
        if ($data) {
            foreach ($data as $key => $row) {
                $data[$key]['type'] = $this->type;
            }

            $this->db->insert_batch('shopify_url', $data);

            return true;
        }

        return false;
    }

    public function no_down_url($web_id)
    {
        $this->db->from('shopify_url');
        $this->db->where('down_num', 0);
        $this->db->where('type', $this->type);
        $this->db->where('web_id', $web_id);
        $this->db->limit(5);
        $query = $this->db->get();

        $shopify_url = $query->result_array();
// print_R($shopify_url);die;
        return $shopify_url;
    }

    public function update_down_num($data, $shopify_id)
    {

        $this->db->where('shopify_id', $shopify_id);
        $this->db->where('type', $this->type);
        $this->db->update('shopify_url', $data);
    }
}